﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Text;
using System.Diagnostics;

namespace WSweb
{
    public class Global : System.Web.HttpApplication
    {
        private static int app_start;
        private static int ses_start;
        private static int app_error;
        private static int ses_end;
        private static int app_end;

        protected void Application_Start(object sender, EventArgs e)
        {
            ++app_start;
        }

        protected void Session_Start(object sender, EventArgs e)
        {
            ++ses_start;
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            ++app_error;
            string url = Request.Path;
            Exception error = Server.GetLastError();
            StringBuilder text = new StringBuilder("Error occurred. ");
            text.Append(error.Message);
            text.Append(" at ");
            text.Append(url);
            EventLog log = new EventLog();
            log.Source = "Error Log(" + DateTime.Now.ToString() + ")";
        }

        protected void Session_End(object sender, EventArgs e)
        {
            ++ses_end;
        }

        protected void Application_End(object sender, EventArgs e)
        {
            ++app_end;
        }
    }
}